home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
qlib205.zip
/
QLIB.ZIP
/
SRC
/
QLIB
/
STRN.ASM
< prev
next >
Wrap
Assembly Source File
|
1997-01-09
|
2KB
|
133 lines
include qlib.inc ;setup
include dos.inc
include string.inc
include alloc.inc
.code
strncpy proc,s1off:dword,s2off:dword,siz:dword
;s1=s2
pushad
mov edi,s1off
mov esi,s2off
callp strlen,esi
.if eax>=siz
mov ecx,siz
rep movsb
.else
mov ecx,eax
rep movsb
mov ecx,siz
sub ecx,eax
mov al,0
rep stosb
.endif
popad
mov eax,s1off
ret
strncpy endp
strncat proc,s1off:dword,s2off:dword,siz:dword
;s1=s1+s2
pushad
mov edi,s1off
mov esi,s2off
callp strlen,esi
mov ecx,eax
.if ecx>siz
mov ecx,siz
.endif
callp strlen,edi
add edi,eax
rep movsb
mov al,0
stosb
popad
mov eax,s1off
ret
strncat endp
strncmp proc,p1:dword,p2:dword,siz:dword
pushad
mov esi,p1
mov edi,p2
mov ecx,siz
@@:
.if !ecx
popad
xor eax,eax
ret
.endif
cmpsb
ja above
jb below
dec ecx
cmp byte ptr[esi-1],0
jnz @b
popad
xor eax,eax
ret
above:
popad
mov eax,1 ;p1 > p2
ret
below:
popad
mov eax,-1 ;p1 < p2
ret
strncmp endp
strnset proc uses edi ecx,s1:dword,c1:byte,siz:dword
mov edi,s1
callp strlen,edi
mov ecx,eax
.if ecx>siz
mov ecx,siz
.endif
mov al,c1
rep stosb
mov eax,s1
ret
strnset endp
strnicmp proc,s1:dword,s2:dword,siz:dword
pushad
mov esi,s1
mov edi,s2
mov ecx,siz
@@:
.if !ecx
popad
xor eax,eax
ret
.endif
lodsb
.if (al>='a') && (al<='z')
add al,'A'-'a'
.endif
mov bl,al
mov al,[edi]
inc edi
.if (al>='a') && (al<='z')
add al,'A'-'a'
.endif
cmp bl,al
ja above
jb below
dec ecx
cmp byte ptr[esi-1],0
jnz @b
popad
xor eax,eax
ret
above:
popad
mov eax,1 ;p1 > p2
ret
below:
popad
mov eax,-1 ;p1 < p2
ret
strnicmp endp
end